﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WEALTH.Manager.Customer
{
    public partial class EditZiChan : BasePage
    {
        private ExcuteDao InformationManage = new ExcuteDao();

        public bool isGiftFlag = false;
        /// <summary>
        /// 页面初始化加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                SetMenu();
                if (!string.IsNullOrEmpty(Request.QueryString["InformationID"]))
                {
                    Session["UrlType"] = "EditInformation";
                    Session["Edit_InformationID"] = SpecialCharHandler.HtmlDiscode(Request.QueryString["InformationID"]).Replace("&amp;", "&");
                    SetInitData();

                }
            }
        }

        private void SetMenu()
        {
            ddlListMenu.Items.Clear();
            ddlListMenu.Items.Add(new ListItem("", "-1"));

            ddlListMenu.Items.Add(new ListItem("已处理", "1"));
            ddlListMenu.Items.Add(new ListItem("未处理", "2"));
        }

        /// <summary>
        /// 设置初始化页面信息
        /// </summary>
        private void SetInitData()
        {
            //获取用户信息
            DataTable dtInformation = InformationManage.Get_ziChanSettingBYID(Request.QueryString["InformationID"]);
            if (dtInformation.Rows.Count > 0)
            {
                this.status.Value = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["status"].ToString());
                this.txtName.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtName"].ToString());
                this.txtPhone.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtPhone"].ToString());
                this.txtHealth.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtHealth"].ToString());
                this.txtCost.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtCost"].ToString());
                this.drpWorkType.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["drpWorkType"].ToString());
                this.isMyComp.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["isMyComp"].ToString());
                this.moneyFrom.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["moneyFrom"].ToString());
                this.txtMoney.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtMoney"].ToString());
                this.agoBuyList.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["drpHomeCost"].ToString());
                this.txtTZFX.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtTZFX"].ToString());
                this.agoBuyList.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["agoBuyList"].ToString());
                this.tuoZiGuanZhu.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["tuoZiGuanZhu"].ToString());
                this.ziXunFrom.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["ziXunFrom"].ToString());
                this.txtTotalMoney.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtTotalMoney"].ToString());
                this.txtJYBaozhang.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtJYBaozhang"].ToString());
                this.txtGoalEndData.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtGoalEndData"].ToString());
                this.txtGoalDesc.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtGoalDesc"].ToString());
                this.txtGoalMoney.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtGoalMoney"].ToString());
                this.txtGoalDesc2.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtGoalDesc2"].ToString());
                this.txtGZ.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtGZ"].ToString());
                this.txtKX.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtKX"].ToString());
                this.txtWifeMoney.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtWifeMoney"].ToString());
                this.txtHospital.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtHospital"].ToString());
                this.txtPrize.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtPrize"].ToString());
                this.txtEducation.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtEducation"].ToString());
                this.txtLiXi.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtLiXi"].ToString());
                this.txtBX.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtBX"].ToString());
                this.txtRent.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtRent"].ToString());
                this.txtQTZC.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtQTZC"].ToString());
                this.txtQTSR.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtQTSR"].ToString());
                this.txtPayRate.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtPayRate"].ToString());
                this.txtSRRate.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtSRRate"].ToString());
                this.txtCushType.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtCushType"].ToString());
                this.txtGJJ.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtGJJ"].ToString());
                this.txtGDSY.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtGDSY"].ToString());
                this.txtGRJD.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtGRJD"].ToString());
                this.txtFDSY.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtFDSY"].ToString());
                this.txtSYZF.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtSYZF"].ToString());
                this.txtBDC.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtBDC"].ToString());
                this.txtQTFZ.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtQTFZ"].ToString());
                this.txtBXType.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtBXType"].ToString());
                this.txtQTZCType.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtQTZCType"].ToString());
                this.txtKTZGM.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["txtKTZGM"].ToString());
                this.txtMemo.Text = SpecialCharHandler.HtmlDiscode(dtInformation.Rows[0]["memo"].ToString());

            }
            //InformationFilter.Information_pwd = dtInformation.Rows[0]["Information_Pwd"].ToString();
        }

        /// <summary>
        /// 编辑按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                //判断是否保存成功
                bool isOk = false;

                //添加用户信息到数据库中
                if (InformationManage.Get_ziChanSetting_Update(
                    Request.QueryString["InformationID"],
                    ddlListMenu.SelectedValue,
                    SpecialCharHandler.HtmlEncode(txtMemo.Text)) == -1)
                {
                    isOk = true;
                }

                if (isOk)
                {
                    ReturnList("ziChanSettingList.aspx", "编辑信息成功！");

                }
                else
                {
                    ShowMsg("编辑信息失败，请确认！", 1);
                }
            }
            catch (Exception ex)
            {
                ShowMsg(ex.Message.ToString(), 1);
            }
        }

    }
}